﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class tblProduct : System.Web.UI.Page
{
    Product pd = new Product();
    static PagedDataSource p = new PagedDataSource();
    public static int intSTT;
    public static int page = 0;
    public static string cid = null;
    public void loaddata(string id)
    {
        try
        {
            p.DataSource = pd.LoadProduct(id);
            p.PageSize = 6;
            p.CurrentPageIndex = page;
            p.AllowPaging = true;
            lbtnFirst.Enabled = true; lbtnPrevious.Enabled = true; lbtnNext.Enabled = true; lbtnLast.Enabled = true;
            if (p.IsFirstPage == true)
            {
                lbtnFirst.Enabled = false;
                lbtnPrevious.Enabled = false;
                lbtnNext.Enabled = true;
                lbtnLast.Enabled = true;
            }
            if (p.IsLastPage == true)
            {
                lbtnFirst.Enabled = true;
                lbtnPrevious.Enabled = true;
                lbtnNext.Enabled = false;
                lbtnLast.Enabled = false;
            }
            txtShow.Text = (page + 1) + " / " + p.PageCount;
            dtlShow.DataSource = p;
            dtlShow.DataBind();
        }
        catch (Exception)
        {
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (IsPostBack == false)
        {
            page = 0;
            cid = "CL01";
            loaddata("Fashion");
            lblTitle1.Text = "Fashion";
            lbtnFashion.ForeColor = System.Drawing.Color.Red;
        }

    }
    protected void lbtnFashion_Click(object sender, EventArgs e)
    {
        lblTitle1.Text = "Fashion";
        lbtnFashion.ForeColor = System.Drawing.Color.Red;
        lbtnElectron.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnBeautify.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnFurniture.ForeColor = System.Drawing.Color.SkyBlue;
        page = 0;
        cid = "CL01";
        loaddata(cid);
    }
    protected void lbtnElectron_Click(object sender, EventArgs e)
    {
        page = 0;
        lblTitle1.Text = "Electron";
        lbtnFashion.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnElectron.ForeColor = System.Drawing.Color.Red;
        lbtnBeautify.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnFurniture.ForeColor = System.Drawing.Color.SkyBlue;
        cid = "CL02";
        loaddata(cid);
    }
    protected void lbtnBeautify_Click(object sender, EventArgs e)
    {
        page = 0;
        lblTitle1.Text = "Beautify";
        lbtnFashion.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnElectron.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnBeautify.ForeColor = System.Drawing.Color.Red;
        lbtnFurniture.ForeColor = System.Drawing.Color.SkyBlue;
        cid = "CL03";
        loaddata(cid);
    }
    protected void lbtnFurniture_Click(object sender, EventArgs e)
    {
        page = 0;
        lblTitle1.Text = "Furniture";
        lbtnFashion.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnElectron.ForeColor = System.Drawing.Color.SkyBlue;
        lbtnBeautify.ForeColor = System.Drawing.Color.Red;
        lbtnFurniture.ForeColor = System.Drawing.Color.SkyBlue;
        cid = "CL04";
        loaddata(cid);
    }
    protected void lbtnFirst_Click(object sender, EventArgs e)
    {
        page = 0;
        loaddata(cid);
    }
    protected void lbtnPrevious_Click(object sender, EventArgs e)
    {
        page = page -1;
        loaddata(cid);
    }
    protected void lbtnNext_Click(object sender, EventArgs e)
    {
        page = page +1;
        loaddata(cid);
    }
    protected void lbtnLast_Click(object sender, EventArgs e)
    {

        page =p.PageCount - 1 ;
        loaddata(cid);
    }
}